home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / PPPOn 1.0.1 / src / macppp / ppp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-20  |  24.5 KB  |  613 lines  |  [TEXT/CWIE]

  1. /*
  2.  * Include file for MacPPP.  Should be pre-compiled with THINK C
  3.  *    to generate the ppp.h file.
  4.  *
  5.  * Copyright 1992-1993 Merit Network, Inc. and The Regents of the
  6.  *  University of Michigan.  Usage of this source code is restricted
  7.  *  to non-profit, non-commercial purposes.  The source is provided
  8.  *  "as-is", without warranty.
  9.  */
  10. #ifndef _PPP_H
  11. #define _PPP_H
  12.  
  13. #include <Timer.h>
  14.  
  15. /* uncomment this if you want alot of DebugStr statements */
  16. #define PPP_DEBUG_CHECKS(x)    /* DebugStr(x) */
  17. /* uncomment below if you want to log certain events to memory */
  18. /* #define LOG */
  19. #pragma options(check_ptrs)
  20.  
  21. #define    uchar(x) ((unsigned char)(x))
  22.  
  23. #include "MacTCPCommonTypes.h"
  24.  
  25. typedef struct LapInfo    LapInfo;
  26. typedef struct PPPiopb    PPPiopb;
  27. typedef struct sdiopb    sdiopb;
  28. typedef struct TMtimer    TMtimer;
  29.  
  30. #include "headers.h"        /* TCP/IP header structures */
  31. #include "slhc.h"
  32.  
  33. /* iopbs to queue transmit requests */
  34. #define    NUMIOPBS 24
  35.  
  36. /* define size for transmit fifo */
  37. #define XMITQLEN 256
  38. #define MAXXMIT 64
  39.  
  40. /* size for receive buffer (to get data from serial driver with PBRead) */
  41. #define RXBUFSIZE 192
  42.  
  43. /* size for receive driver input buffer */
  44. /* this needs to be fairly large for slow Macs to run at higher speeds */
  45. #define SDINBUFLEN 1024
  46.  
  47. #define PARAM_DOWN    0x81
  48. #define PARAM_UP    0x82
  49.  
  50. #define TASK_QUEUED 0x8000
  51.  
  52. /* Lap Transition events */
  53. #define    TransitionOpen  0L
  54. #define    TransitionClose 2L
  55.  
  56. /* Basic buffer structure */
  57. struct bufheader {
  58.     b_8        *dataptr;    /* pointer to start of data */
  59.     short    length;        /* length of data */
  60. };
  61.  
  62. #define    YANKBYTE(bufptr)\
  63.  (bufptr->length != 0 ? \
  64.  (bufptr->length--, *bufptr->dataptr++) : -1)
  65.  
  66. #define PPP_IP_PROTOCOL     0x0021
  67. #define PPP_VJ_COMP_PROTOCOL    0x002D
  68. #define PPP_COMPR_PROTOCOL    0x002D
  69. #define PPP_VJ_UNCOMP_PROTOCOL    0x002F
  70. #define PPP_UNCOMP_PROTOCOL    0x002F
  71. #define PPP_IPCP_PROTOCOL    0x8021
  72. #define PPP_LCP_PROTOCOL    0xC021
  73. #define PPP_PAP_PROTOCOL    0xC023
  74. #define HDLC_ALL_ADDR    0xff    /* HDLC all-station */
  75. #define HDLC_UI            0x03    /* HDLC Unnumbered Information */
  76. #define PPP_HDR_LEN    4    /* Max bytes for PPP/HDLC envelope header */
  77.  
  78. /* character defines */
  79. #define ENTER 3
  80. #define RETURN 13
  81. #define TAB 9
  82. #define BACKSPACE 8
  83.  
  84. /*
  85.  *  Timer
  86.  */
  87.  
  88. #define NULLTIMER    (struct TMtimer *)0
  89.  
  90. struct TMtimer
  91. {
  92.     TMTask            atm;        /* time manager task struct */
  93.     long            duration;    /* millisecond delay (must be positive) */
  94.     struct fsm_s    *fsm_p;        /* pointer to fsm to which this belongs */
  95.     ProcPtr        proc;        /* procedure to execute on timeout */
  96.     b_8                state;        /* state of the this timer */
  97. };
  98.  
  99. /* Timer states */
  100. #define TIMER_STOP    0
  101. #define TIMER_RUN    1
  102. #define TIMER_EXPIRE    2
  103.  
  104. struct TMprocess
  105. {
  106.     TMTask            atm;
  107.     union {
  108.         LapInfo            *lap;        /* place to save our lap pointer */
  109.         struct fsm_s    *fsm_p;        /* fsm pointer */
  110.     } tmsavptr;
  111. };
  112.  
  113. /*
  114.  *  PPP characters
  115.  */
  116.  
  117. enum {    PPP_FLAG    =   0x7E,   /* Opening/closing frame flag */
  118.     PPP_ESCAPE    =   0x7D   /* escape next character */
  119. };
  120.  
  121. typedef enum { s_Idle, s_Data, s_Escape, 
  122.                   s_Init, s_Finish, s_SendFCS, s_Loopback } HDLCState;
  123.  
  124. #define FCS_INIT    0xFFFF
  125. #define FCS_TERM    0xF0B8
  126. /* config packet header */
  127. struct config_hdr {
  128.     b_8 code;
  129. #define CONFIG_REQ     1
  130. #define CONFIG_ACK     2
  131. #define CONFIG_NAK     3
  132. #define CONFIG_REJ     4
  133. #define TERM_REQ     5
  134. #define TERM_ACK     6
  135. #define CODE_REJ     7
  136. #define PROT_REJ     8
  137. #define ECHO_REQ     9
  138. #define ECHO_REPLY    10
  139. #define DISCARD_REQ    11
  140.  
  141.     b_8 id;
  142.     b_16 len;
  143. };
  144. #define CONFIG_HDR_LEN    4    /* Length of config packet header */
  145.  
  146. /* config option header */
  147. struct option_hdr {
  148.     b_8 type;        /* protocol dependant types */
  149.     b_8 len;
  150. };
  151. #define OPTION_HDR_LEN    2    /* Length of option header */
  152.  
  153. /* Supported Configuration Protocol index */
  154. enum { Lcp, Pap, IPcp, fsmi_Size };
  155.  
  156. /* Protocol Constants needed by State Machine */
  157. struct fsm_constant_s {
  158.     b_16    protocol;        /* Protocol number */
  159.     b_8        fsmi;            /* Finite State Machine index */
  160.     b_8        try_req;        /* # of tries for config request */
  161.     b_8        try_nak;        /* # tries for nak substitutes */
  162.     b_8        try_terminate;    /* # tries for terminate */
  163.     b_8        *option_lengths;    /* ptr to array of option lengths */
  164.     b_8        option_limit;    /* # of options recognized */
  165.     b_8        timeout;        /* Time for timeouts (seconds)*/
  166. };
  167.  
  168. /* FSM states */
  169. enum { fsmINITIAL, fsmSTARTING, fsmCLOSED, fsmSTOPPED, fsmCLOSING, fsmSTOPPING,
  170.         fsmREQ_Sent, fsmACK_Rcvd, fsmACK_Sent, fsmOPENED, fsmState_Size };
  171.  
  172. /* State Machine Control Block */
  173. struct fsm_s {
  174.     b_8        state;            /* FSM state */
  175.     b_8        lastid;            /* ID of last REQ we sent */
  176.     b_8        retry;            /* counter for timeouts */
  177.     b_8        retry_nak;        /* counter for naks of requests */
  178.     LapInfo *lap;            /* place to stuff lap pointer */
  179.     struct    TMtimer timer;
  180.     struct    fsm_constant_s pdc;    /* protocol dependent constants */
  181.     void    *pdv;            /* pointer to protocol dependent variables */
  182. };
  183.  
  184. /* Link Phases */
  185. enum {
  186.     pppDEAD = 0,    /* Link Dead, Waiting for physical layer */
  187.     pppESTABLISH,    /* Link Establishment (LCP) phase */
  188.     pppAUTHENTICATE,    /* Authentication Phase */
  189.     pppNETWORK,        /* Network-Layer Protocol Phase */
  190.     pppTERMINATE,    /* Link Termination Phase */
  191.     pppPhase_Size
  192. };
  193.  
  194.                     /* LCP option types */
  195. #define LCP_MRU            0x01
  196. #define LCP_ACCM        0x02
  197. #define LCP_AUTHENT        0x03
  198. #define LCP_QUALITY        0x04
  199. #define LCP_MAGIC        0x05
  200. #define LCP_PFC            0x07
  201. #define LCP_ACFC        0x08
  202. #define LCP_OPTION_LIMIT    0x08    /* highest # we can handle */
  203. #define LCP_N_MRU        (1 << LCP_MRU)
  204. #define LCP_N_ACCM        (1 << LCP_ACCM)
  205. #define LCP_N_AUTHENT    (1 << LCP_AUTHENT)
  206. #define LCP_N_MAGIC        (1 << LCP_MAGIC)
  207. #define LCP_N_QUALITY    (1 << LCP_QUALITY)
  208. #define LCP_N_PFC        (1 << LCP_PFC)
  209. #define LCP_N_ACFC        (1 << LCP_ACFC)
  210.  
  211. /* Table for LCP configuration requests */
  212. struct lcp_value_s {
  213.     b_16    mru;            /* Maximum Receive Unit */
  214.     b_16    authentication;    /* Authentication protocol */
  215.     b_32    accm;            /* Async Control Char Map */
  216.     b_32    magic_number;    /* Magic number value */
  217. };
  218.  
  219. /* for test purposes, accept anything we understand in the NAK */
  220. #define LCP_NEG LCP_N_MRU | LCP_N_ACCM | LCP_N_AUTHENT | LCP_N_PFC | LCP_N_ACFC | LCP_N_MAGIC
  221.  
  222. /* Other configuration option values */
  223. #define LCP_ACCM_DEFAULT    0xffffffffL
  224. #define LCP_MRU_DEFAULT    1500
  225. #define LCP_MRU_HI    1500    /* High MRU limit */
  226. #define LCP_MRU_LO    128        /* Lower MRU limit */
  227.  
  228. #define PPP_OVERHEAD 8        /* room for addr, cntl, protocol and 32-bit FCS */
  229. #define    PPP_BUFSIZE LCP_MRU_HI + PPP_OVERHEAD /* size of buf for PPP packet */
  230.  
  231. #define LCP_NAK_TRY    10        /* NAK attempts */
  232. #define LCP_TERM_TRY 2        /* tries on TERM REQ */
  233.  
  234. /* PAP Parameters */
  235. #define PAPMESSLEN 128
  236. #define PAPUSERLEN 32
  237. #define PAPPASSLEN 32
  238.     /* PAP control block */
  239. struct pap_s {
  240.     b_8        username[PAPUSERLEN];    /* Username for REQ */
  241.     b_8        password[PAPPASSLEN];    /* Password for REQ */
  242.     b_8        message[PAPMESSLEN];    /* message from last ACK/NAK */
  243.     b_8        IOFlag;            /* flag to indicate userio necessary */
  244. };
  245.  
  246.  
  247.                     /* IPCP option types */
  248. #define IPCP_COMPRESS        0x02
  249. #define IPCP_ADDRESSES        0x01
  250. #define IPCP_ADDRESS        0x03    /* newer IP ADDRESS negotiation */
  251. #define IPCP_OPTION_LIMIT    0x03    /* highest # we can handle */
  252. #define IPCP_N_ADDRESS        (1 << IPCP_ADDRESS)
  253. #define IPCP_N_COMPRESS        (1 << IPCP_COMPRESS)
  254. #define IPCP_N_ADDRESSES    (1 << IPCP_ADDRESSES)
  255.  
  256. /* Table for IPCP configuration re[33];        /* ### */
  257. /* align to word */
  258.     Byte        load;
  259.     Byte        admin;
  260.     Byte        netLock;
  261.     Byte        subnetLock;
  262.     Byte        nodeLock;
  263.     Byte        filler1;
  264.     long        activeLap;
  265.     long        slot;
  266.     char        filename[33];        /* ### */
  267. };
  268.  
  269. struct icmpEchoInfo {
  270.     unsigned long    echoRequestOut;    /* time when echo req. went out */
  271.     unsigned long    echoReplyIn;    /* time when echo reply received */
  272.     struct rdsEntry    echoedData;    /* data received in response */
  273.     Ptr        options;    /* IP Options */
  274.     unsigned long    userDataPtr;    /* userDataPtr for app stuff */
  275. };
  276.  
  277. typedef struct ipbuf {
  278.     IOParam        iop;        /* MAC OS I/O Param block */
  279.     struct icmpEchoInfo    echoInfo;    /* ping stuff */
  280.     struct ipbuf    *segipb;    /* pointer to segment's IPB if fragmented */
  281.     struct LapInfo    *lap;        /* LAP pointer */
  282.     ProcPtr        lap_ioc;     /* local net completion routine */
  283.     ProcPtr        ip_ioc;        /* IP completion routine */
  284.     ProcPtr        tp_ioc;        /* transport completion routine */
  285.     ProcPtr        data_ioc;    /* data IOC */
  286.     struct wdsEntry    laphdr;        /* local net header */
  287.     struct wdsEntry    ip;        /* IP header */
  288.     struct wdsEntry    tp;        /* TCP/UDP or ICMP header */
  289.     struct wdsEntry    data;        /* TCP/UDP data */
  290.     struct wdsEntry    d1;
  291.     struct wdsEntry    d2;
  292.     struct wdsEntry    d3;
  293.     struct wdsEntry    d4;        /* 8 wds entries plus 0 terminator */
  294.     short        flag;        /* zero terminator to WDS */
  295.     char        packet[];    /* start of variable length pkt */
  296. } ipbuf;
  297.  
  298. struct rdStruct {
  299.     ProcPtr    ph_rp;        /* pointer to "ReadPacket" routine (a4)    */
  300.     ProcPtr    ph_rr;        /* pointer to "ReadRest" routine 2(a4)    */
  301.     long    ph_bytesleft;    /* number of bytes left to read    */
  302.     union {
  303.         struct {    /* storage for standard AppleTalk LAP protocol handler */
  304.             long    phb_a4;        /* used by driver    */
  305.             long    phb_a0;        /* used by driver    */
  306.             long    phb_a1;        /* used by driver    */
  307.             long    phb_a2;        /* used by driver    */
  308.             } phb;
  309.         struct {    /* storage for a buffered LAP interface */
  310.             b_8    *lnb_ptr;    /* pointer to next byte to get from buffer    */
  311.             } lnb;
  312.         struct {    /* storage for a reassembled IP packet */
  313.             struct fragment    *rsmb_fragbuffer;    /* buffer to fragment data buffer */
  314.             b_8    *rsmb_ptr;    /* pointer to next byte to get from buffer */
  315.             long    rsmb_bytesleft;    /* number of bytes left in this buffer */
  316.             long    rsmb_byteoffset;/* offset of next byte in rsm'd pkt */
  317.             } rsm;
  318.         } rdsparm;
  319.     Byte    lapBroadcast;    /* LAP-level broadcast */
  320.     Byte    ipBroadcast;    /* IP-level broadcast */
  321.     struct LapInfo    *lap;
  322.     struct wdsEntry    laphdr;    /* local net header */
  323.     struct wdsEntry    ip;    /* ip header !!! (IPwdsEntry) ???*/
  324.     struct wdsEntry    tp;    /* TCP/UDP or ICMP header */
  325.     struct wdsEntry    data;    /* TCP/UDP data */
  326. };
  327.  
  328. struct sdiopb {
  329.     IOParam        iop;    /* IOPB for serial driver use */
  330.     LapInfo        *lap;    /* ptr to LapInfo */
  331.     };
  332.     
  333. typedef unsigned long (*longProcPtr)();
  334.  
  335. #define BUFOFFSET sizeof(struct bufheader) + sizeof(struct ipheader) + sizeof(struct tcpheader)
  336. #define    BUFFERSIZE PPP_BUFSIZE + BUFOFFSET
  337. #define NUMBUFFERS 4    /* number of buffers to allocate */
  338. #define LCP_ECHO_BUFSIZE 12 /* buffer size for lcp echo requests */
  339.  
  340. struct LapInfo {
  341.     b_32        cur_ip_addr;    /* LAP's IP address */
  342.     b_32        cur_net_mask;    /* LAP's IP net-mask */
  343.     b_32        ip_broadcast_addr;    /* IP's broadcast address */
  344.     struct IPCONFIG    lc;        /* copy of IP LAP cnfg rsrc */
  345.     ProcPtr    lapInit;    /* ptr to LAP init routine */
  346.     ProcPtr    lapOpen;    /* LAP open rtn */
  347.     ProcPtr    lapClose;    /* LAP close rtn */
  348.     ProcPtr        lapUnload;    /* LAP unload rtn, undoes lapInit */
  349.     ProcPtr    lapAttach;    /* LAP attach PH rtn */
  350.     ProcPtr    lapDetach;    /* LAP detach PH rtn */
  351.     ProcPtr    lapOutput;    /* LAP output rtn */
  352.     ProcPtr    lapControl;    /* LAP control rtn */
  353.     ProcPtr        lapFault;    /* LAP fault isolation rtn */
  354.     ProcPtr    lapStatistics;    /* LAP statistic reading rtn */
  355.     ProcPtr        lapConfigure;    /* LAP configuration rtn */
  356.     ProcPtr    lapProbe;    /* send a LAP-specific addr probe pkt */
  357.     ProcPtr    lapRegister;    /* register our IP address on net */
  358.     ProcPtr        lapFindGateway;    /* LAP-specific way to find gateway  */
  359.     ProcPtr    lapGwyCheck;    /* LAP-specific way to gateway is up */
  360. /* IP Parameters */
  361.     ip_addr        dfl_dns_addr;    /* addr of DNS from config protocol */
  362.     Handle        dnslHndl;    /* handle to DNS config rsrc */
  363.     Ptr            dnsCache;    /* ptr to DNS cache area */
  364.     long        dnsCacheSize;    /* size of cache in bytes */
  365. /* LAP Parameters */
  366.     long        headerSize;    /* LAP header space required */
  367.     long        trailerSize;    /* LAP trailer space required */
  368.     long        outMaxPacketSize;    /* max output packet size */
  369.     long        inMaxPacketSize;    /* max input packet size */
  370.     long        maxDataSize;    /* max size of data packet */
  371.     long        numConnections;    /* number of separate net connections */
  372.     unsigned long    versionFlags;    /* version number flags */
  373.     ProcPtr    ip_ph;        /* ptr to IP protocol handler */
  374.     Ptr            ipGlobals;    /* ptr to IP's A5 */
  375.     short        link_unit;    /* unit number of link driver */
  376.     Byte        addressConflict;    /* TRUE is address conflict */
  377.     long        lapType;    /* IP LAP hardware type # */
  378.     long        lapAddrLength;    /* size of LAP address field */
  379.     unsigned char     *lapAddrPtr;    /* ptr to LAP address field */
  380.     unsigned long    reserved;    /* MacTCP reserved field */
  381.     /* PPP specific storage */
  382.     Boolean        ok_to_xmit;    /* ok to transmit on serial port */
  383.     Boolean        term_mode;    /* terminal emulation flag */
  384.     Boolean        needTxPrime;    /* transmit routine needs to be primed */
  385.     Boolean        HasDeferredTasks;    /* indicates if Deferred Tasks available */
  386.     short        serinrefnum;    /* serial input ref num */
  387.     short        seroutrefnum;    /* serial output ref num */
  388.     b_8            rxbuf[RXBUFSIZE];    /* small receive buffer to get data from driver */
  389.     longProcPtr    transProc;    /* ptr to transition Proc */
  390.     longProcPtr savProc;    /* place to save a copy of transition proc pointer */
  391.     Ptr            LapA4;        /* holder for LAP's A4 */
  392.     HDLCState    read_state;    /* state of PPP receiver */
  393.     HDLCState    write_state;    /* state of PPP transmitter */
  394.     short        echo_count;    /* count of outstanding LCP echo requests */
  395.     short        idle_timer;    /* number of idle minutes */
  396.     short        writerr;    /* error on write. Who knows what */
  397.     short        readerr;    /* receiver errors */
  398.     OSErr        lasterr;    /* rc of last PBRead != noErr */
  399.     short        outofiopbs;    /* write failed; too many dgs q'd */
  400.     short        faults;        /* PPPFault was called. */
  401.     short        OutofBuffers;    /* # of getbuffer failures */
  402.     long        OutTxOctetCount;/* # octets sent */
  403.     long        OutOpenFlag;    /* # of open flags sent */
  404.     short        OutError;        /* # packets with error on send */
  405.     long        InRxOctetCount;    /* # octets received */
  406.     long        InOpenFlag;        /* # of open flags */
  407.     short        InUnknown;        /* # unknown packets received */
  408.     short        InCheckSeq;        /* # packets with bad check sequence */
  409.     short        InFramingErr;    /* # framing errors */
  410.     short        InError;        /* # packets with other error */
  411.     short        InIdleToss;        /* non-flag chars while Idle */
  412.     short        InHeader;        /*  Header errors */
  413.     short        InFrameOvr;        /* frame overrun */
  414.     short        InSoftOvr;        /* software overrun */
  415.     short        InHardOvr;        /* hardware overrun */
  416.     struct bufheader    *bufptr; /* current buffer for receive data */
  417.     b_8            *rddata;        /* pointer to end of data in rcv. buffer */
  418.     b_8            xbuf[8];        /* small buffer for copying to fifo */
  419.     struct { 
  420.         b_8        block[BUFFERSIZE];
  421.     } blockarray[NUMBUFFERS];    /* storage for memory blocks */
  422.     struct bufheader *buflist;    /* pointer to buffer list */
  423.     struct {                    /* a small buffer for LCP echo requests */
  424.         struct bufheader header;    /* a fake header for the buffer */
  425.         b_8        buffer[LCP_ECHO_BUFSIZE];    /* the actual buffer */
  426.     } lcp_echo_buf;
  427.     QHdr        out_q;            /* q of packets to write */
  428.     QHdr        pppbq;            /* Q of free PPPiopbs */
  429.     PPPiopb        *active;        /* current PPPiopb to transmit */
  430.     PPPiopb        pppiopbs[NUMIOPBS];    /* define storage for iopbs */
  431.     sdiopb        w_iopb;            /* IOPB for serial port writes */
  432.     sdiopb        r_iopb;            /* IOPB for serial port reads */
  433.     CntrlParam    stat_pb;        /* cntrlParam block for status calls */
  434.     struct rdStruct        rds;    /* for passing to ip layer */
  435.     struct ppp_pref    prefdata;    /* Data from Preferences file */
  436.     struct ppp_config configdata;    /* more preferences */
  437.     b_32        PPP_RecvACM;    /* Async Control maps */
  438.     b_32        PPP_XmitACM;
  439.     b_32        PPP_activeACM;    /* current active transmit ACCM */
  440.     b_16        fcstab[256];    /* FCS table for quicker FCS's */
  441.     b_16        XmitFCS;        /* FCS for current transmit frame */
  442.     b_16        RecvFCS;        /* FCS for current rx frame */
  443.     struct    NMRec        closenmtask;    /* Notification task record to close link */
  444.     struct    TMprocess    rxp_task;    /* receive processing task structure */
  445.     struct    TMprocess    txp_task;    /* transmit process task structure */
  446.     struct  TMprocess    echo_task;    /* LCP echo process */
  447.     struct    TMprocess    timeout_task;    /* idle timeout process */
  448.     DeferredTask defer_tx, defer_rx, defer_txcomplete;
  449.     b_8        sdinbuf[SDINBUFLEN]; /* input buffer for serial driver receive */
  450.     b_16    XmitQHead;            /* transmit queue head index */
  451.     b_16    XmitQTail;            /* transmit queue tail index */
  452.     b_16    XmitQSize;            /* transmit queue size */
  453.     b_8        XmitQ[XMITQLEN];    /* transmit queue */
  454.     struct proto_s    lcp_i, ipcp_i;
  455.     struct pap_s    pap_i;
  456.     b_8        ppp_phase;            /* phase of link initialization */
  457.     b_8        ppp_id;                /* id counter for connection */
  458.     b_32    ppp_upsince;        /* Timestamp when Link Opened */
  459.     b_8        ppp_flags;
  460. #define PPP_AP_REMOTE    0x01    /* remote authentication */
  461. #define ECHO_FAIL        0x02    /* LCP echo timeout */
  462. #define IDLE_TIMEOUT    0x04    /* idle timeout */
  463. #define CLOSE_PPP        0x08    /* close PPP flag */
  464.     struct fsm_s ppp_fsm[fsmi_Size];    /* finite state machines */
  465.     struct slcompress    comp;
  466.     struct cstate    rcvslots[MAXSLOTS],txslots[MAXSLOTS];
  467.     b_8        *lcp_option_length_p; /* lcp option lengths */
  468.     struct    lcp_value_s *lcp_default_p;    /* pointer to default option values */
  469.     b_8        *ipcp_option_length_p; /* ipcp options lengths */
  470.     struct    ipcp_value_s *ipcp_default_p;    /* pointer to default option values */
  471. #ifdef LOG
  472.     int        *logp;
  473.     int        log[5*100];
  474.     int        logend;
  475.     int        cushion[10];
  476. #endif
  477. };
  478.  
  479. typedef struct LapStats {
  480.     short    ifType;
  481.     char    *ifString;
  482.     short    ifMaxMTU;
  483.     long    ifSpeed;
  484.     short    ifPhyAddrLength;
  485.     char    *ifPhysicalAddress;
  486.     union {
  487.             char *noarp;
  488.             } AddrXlation;
  489.     short    slotNumber;
  490. };
  491.     
  492. /* Prototypes and declarations for routines */
  493.  
  494. /* lap.c */
  495. OSErr     PPPInit(    LapInfo *, longProcPtr);
  496. OSErr     PPPOpen(    LapInfo *);
  497. OSErr     PPPClose(    LapInfo *);
  498. void    PPPUnload(    LapInfo *);
  499. OSErr     PPPAttachPH(    LapInfo *, ProcPtr);
  500. OSErr     PPPDetachPH(    LapInfo *);
  501. OSErr     PPPWrite(    LapInfo *, ip_addr, struct ipbuf *);
  502. OSErr     PPPControl(    LapInfo *);
  503. void     PPPFault(    LapInfo *, ip_addr);
  504. void     PPPConfigure(    LapInfo *);
  505. Boolean    PPPProbe(    LapInfo *, ip_addr);
  506. Boolean    PPPRegister(    LapInfo *);
  507. void    PPPFindGW(    LapInfo *);
  508. OSErr     PPPStatistics(    LapInfo *, struct LapStats *);
  509.  
  510. /* misc.c: */
  511. void    AppendStr(b_8 *, b_8 *);
  512. struct bufheader *getbuffer();
  513. void    release(struct bufheader *);
  514. void    makeroom(struct bufheader *, b_16);
  515. b_16    yankbuf(struct bufheader *, b_8 *, b_16);
  516. short    yankbyte(struct bufheader *);    /* returns -1 if nothing */
  517. long    yank16(struct bufheader *);    /* returns -1 if nothing */
  518. b_32    yank32(struct bufheader *);    /* returns  0 if nothing */
  519. short    bytecmp(b_8 *, b_8 *, short);
  520. b_16    get16(b_8 *);
  521. b_32    get32(b_8 *);
  522. b_8        *put16(b_8 *, b_16);
  523. b_8        *put32(b_8 *, b_32);
  524. void    tcp_window_fix(LapInfo *, struct bufheader *);
  525.  
  526. /* fsm.c */
  527. void    htoncnf(struct config_hdr *, struct bufheader *);
  528. short    ntohcnf(struct config_hdr *, struct bufheader *);
  529. short    ntohopt(struct option_hdr *, struct bufheader *);
  530.  
  531. short    fsm_sendtermreq(struct fsm_s *);
  532. short    fsm_sendtermack(struct fsm_s *, b_8);
  533. void    fsm_reset(struct fsm_s *);
  534. void    fsm_tld(struct fsm_s *);
  535. void    fsm_tlu(struct fsm_s *);
  536. void    fsm_tlf(struct fsm_s *);
  537. void    fsm_tls(struct fsm_s *);
  538. void    fsm_no_action(struct fsm_s *);
  539. short    fsm_no_check(struct fsm_s *, struct config_hdr *, struct bufheader *);
  540. void    fsm_log(struct fsm_s *, char *);
  541. void    fsm_timer(struct fsm_s *);
  542. void    fsm_timeout(void);
  543. short    fsm_send(struct fsm_s *, b_8, b_8, struct bufheader *);
  544. short    fsm_sendreq(struct fsm_s *);
  545. void    fsm_proc(struct fsm_s *, struct bufheader *);
  546. void    fsm_open(struct fsm_s *);
  547. void    fsm_down(struct fsm_s *);
  548. void    fsm_close(struct fsm_s *);
  549. void    fsm_init(struct fsm_s *);
  550.  
  551. /* ppp.c */
  552. void    ppp_ready(LapInfo *);
  553. void    ppp_init(LapInfo *);
  554. short    ppp_iostatus(LapInfo *, short);
  555. void    htonppp(LapInfo *, b_16, struct bufheader *);
  556. short    proc_request(struct fsm_s *, struct config_hdr *, struct bufheader *);
  557. short    proc_ack(struct fsm_s *, struct config_hdr *, struct bufheader *);
  558. short    proc_nak(struct fsm_s *, struct config_hdr *, struct bufheader *);
  559. short    proc_reject(struct fsm_s *, struct config_hdr *, struct bufheader *);
  560. short    option_check(struct bufheader *, struct fsm_s *,
  561.                             struct option_hdr *, short);
  562. void    makeoptions(struct fsm_s *, struct bufheader *, union value_s *, b_16);
  563. void    add_option(struct fsm_s *, struct bufheader *, union value_s *,
  564.                         b_8, b_8, struct bufheader *);
  565. struct bufheader *makereq(struct fsm_s *);
  566.  
  567. /* link.c */
  568. void    link_open(LapInfo *);
  569. void    link_close();
  570.  
  571. /* asmutil.c */
  572. void    bzero(b_8 *, short);
  573. void    SetLAPPtr(LapInfo *);
  574. LapInfo    *GetLAPPtr(void);
  575. long    seta5(long);
  576. long    geta5(void);
  577. long    seta4(long);
  578. long    geta4(void);
  579. short    set_sr(short);
  580. short    get_sr(void);
  581.  
  582. /* io.c */
  583. void    RcvDeferred(void);
  584. void    XmtDeferred(void);
  585. void    TxCDeferred(void);
  586. ProcPtr hdlcrioc(void);
  587. ProcPtr    hdlcwioc(void);
  588. OSErr    QueueFrame(LapInfo *, struct bufheader *, struct ipbuf *);
  589. PPPiopb *get_iopb(LapInfo *);
  590. OSErr    readpkt(struct rdStruct *, Ptr, long);
  591. long    readrest(struct rdStruct *, Ptr, long);
  592. void    rcvip(LapInfo *, struct bufheader *);
  593. OSErr    xmit(sdiopb *, b_8 *, long);
  594. void    ProcRcvPPP(void);
  595. void    ProcXmtPPP(LapInfo *);
  596. void    XmtTMProc(void);
  597. void    IOCompleted(LapInfo *, struct ipbuf *);
  598. void    SerComplete(void);
  599. void    SerReadDone(void);
  600.  
  601. /* pap.c */
  602. short    pap_remote(LapInfo *);
  603. void    pap_down(struct fsm_s *);
  604. void    pap_proc(struct fsm_s *, struct bufheader *);
  605. OSErr    pap_userio(struct fsm_s *);
  606.  
  607. /* timer.c */
  608. void    set_timer(TMtimer *, struct fsm_s *, ProcPtr);
  609. void    start_timer(TMtimer *);
  610. void    stop_timer(TMtimer *);
  611.  
  612. #endif /* _PPP_H */
  613.